package main

import "fmt"

type person2 struct {
	name string
	sex  string
	age  int
}

type teacher1 struct {
	person2
	subject string
}

type student2 struct {
	person2
	score int
}

func (s *teacher1) sayHello() {
	fmt.Println(s)
}

func (s *student2) sayHello() {
	fmt.Println(s)
}

type Personer2 interface {
	sayHello()
}

//多态实现
//多态是将接口类型作为函数的参数,多态,实现了接口的统一处理
func SayHello(p Personer2) {
	p.sayHello()
}

func main() {
	var h Personer2
	h = &teacher1{person2{"foo", "男", 19}, "数学"}
	h.sayHello()

	var h1 Personer2
	h1 = &student2{person2{"bar", "男", 20}, 100}
	SayHello(h1)

	h2:=&teacher1{person2{"zs","男",22},"生物"}
	SayHello(h2)
}
